import pymysql

db=pymysql.connect(host='47.103.126.208',port=3306,user='hwr_62',password="123456",database='mall')
#2创建游标
cursor = db.cursor()
# 3执行SQL语句
cursor.execute('select*from ls_order')
# 4拿执行结果
# cursor.fetchone()
# cursor.fetchall()
class Connect_MysQL:
    def __init__(self,host='47.103.126.208',port=3306,user='hwr_62',password="123456",database='mall'):
         db=pymysql.connect(host=host, port=port, user=user, password=password, database=database)
         self.cursor=db.cursor()
    def excute_sql(self,sql,fetch='one'):
        self.cursor.execute(sql)
        if fetch == 'one':
            return self.cursor.fetchone()
        elif fetch =='all':
            return self.cursor.fetchall()

